#pragma once

#include <unordered_map>
#include <string>

struct D3D11_BUFFER_DESC;
struct D3D11_SHADER_RESOURCE_VIEW_DESC;
struct D3D11_SUBRESOURCE_DATA;
struct D3D11_UNORDERED_ACCESS_VIEW_DESC;
struct ID3D11Buffer;
struct ID3D11Resource;
struct ID3D11ShaderResourceView;
struct ID3D11UnorderedAccessView;

/////////////////////////////////////////////////////////////////////
//
// Manage shader resources.
//
////////////////////////////////////////////////////////////////////

class ShaderResources {
	typedef std::unordered_map<std::wstring, ID3D11ShaderResourceView*> ShaderResourceViews;	
	ShaderResourceViews mShaderResourceViews;

	typedef std::unordered_map<std::wstring, ID3D11UnorderedAccessView*> UnorderedAccessViews;
	UnorderedAccessViews mUnorderedAccessViews;

	typedef std::unordered_map<std::wstring, ID3D11Buffer*> Buffers;
	Buffers mBuffers;

public:
	ID3D11ShaderResourceView* addTextureFromFileSRV(const std::wstring& name, const std::wstring& filepath);	

	ID3D11ShaderResourceView* addResourceSRV(const std::wstring& name, ID3D11Resource* resource, const D3D11_SHADER_RESOURCE_VIEW_DESC& desc);

	ID3D11UnorderedAccessView* addResourceUAV(const std::wstring& name, ID3D11Resource* resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC& desc);

	ID3D11Buffer* addBuffer(const std::wstring& name, D3D11_BUFFER_DESC& desc, const D3D11_SUBRESOURCE_DATA* initData);

	ID3D11ShaderResourceView* getShaderResourceView(const std::wstring& name) const;
	ID3D11UnorderedAccessView* getUnorderedAccessView(const std::wstring& name) const;
	ID3D11Buffer* getBuffer(const std::wstring& name) const;

	~ShaderResources();
};

